<?php
class Webkul_Marketplacepartner_Model_Feedback extends Mage_Core_Model_Abstract
{
	 public function _construct() {
        parent::_construct();
        $this->_init('marketplacepartner/feedback');
    }
	public function getTotal($partnerId){
		$data=array();
		if($partnerId > 0){
			$collection = Mage::getResourceModel('marketplacepartner/feedback_collection');
			$collection->getSelect()->where('proownerid ='.$partnerId);
			$price=0;
			$value=0;
			$quality=0;
			foreach($collection as $record) {
				$price=$record->getfeedprice();
				$value=$record->getfeedvalue();
				$quality=$record->getfeedquality();
			}
			$totalfeed=ceil(($price+$value+$quality)/3);
			$data=array('totalfeed'=>$totalfeed, 'feedcount'=>count($collection));
			return $data;
		}
	}
	public function getFeedList($partnerId){
		$data=array();
		if($partnerId > 0){
			$collection = Mage::getModel('marketplacepartner/feedback')->getCollection()
															   ->addFieldToFilter('status',array('neq'=>0))
															   ->addFieldToFilter('proownerid',array('eq'=>$partnerId));
			$i=0;
			foreach($collection as $record) {
				$data[$i]=array(
								'userid'=>$record->getuserid(),
								'feedprice'=>$record->getfeedprice(),
								'feedvalue'=>$record->getfeedvalue(),
								'feedquality'=>$record->getfeedquality(),
								'feedreview'=>$record->getfeedreview(),
								'createdat'=>$record->getcreatedat()
								);
				$i++;
			}
			return $data;
		}
	
	}
	
	public function saveFeedbackdetail($wholedata)
	{
	$collection=Mage::getModel('marketplacepartner/feedback');
	$collection->setData($wholedata);
	$collection->save();
	return 0;
	}
}